<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
    <title>管理后台</title>
        <link href="/favicon.ico" type="image/x-icon" rel="shortcut icon" />
    <!--[if lt IE 8]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->

    <link href="/public/static/admin/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="/public/static/admin/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="/public/static/admin/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="/public/static/admin/css/animate.css" rel="stylesheet">
    <link href="/public/static/admin/css/style.css?v=4.0.0" rel="stylesheet">
    <link href="/public/static/admin/css/ourstyle.css?v=4.0.0" rel="stylesheet">
    <link href="/public/static/admin/css/ratuo.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="/public/webuploader/webuploader.css">

    <!-- 全局js -->
    <script src="/public/static/admin/js/jquery.min.js?v=2.1.4"></script>
    <script src="/public/static/admin/js/bootstrap.min.js?v=3.3.5"></script>
    <!-- 自定义js -->
    <script src="/public/static/admin/js/content.js?v=1.0.0"></script>

    <!-- iCheck -->
    <script src="/public/static/admin/js/plugins/iCheck/icheck.min.js"></script>
    <script src="/public/static/admin/js/plugins/layer/layer.min.js"></script>

    <script src="/public/static/admin/js/rt_common.js?v=4.0.1"></script> 
    <script src="/public/static/admin/js/rt_post.js?v=4.0.0"></script>
    <script src="/public/static/admin/js/jquery.validate.js"></script>
    <script src="/public/static/admin/plugins/laydate/laydate.js"></script>
    <script src="/public/static/admin/js/jquery-form.js"></script>

    <!-- Tell the browser to be responsive to screen width -->
    <!-- webuploader -->
     <script type="text/javascript" src="/public/webuploader/webuploader.nolog.js"></script>
     <!-- kindeditor -->
    <script src="/public/kindeditor/kindeditor-all-min.js"></script>
    <script src="/public/kindeditor/lang/zh-CN.js"></script>
    <!-- plupload -->
    <script type="text/javascript" src="/public/plupload/plupload.full.min.js"></script>
<script language="javascript">
<!--
KindEditor.ready(function(K) {
    K.create('#goods_content', {
        themeType : 'default',
        width : '100%',
        afterBlur:function(){this.sync();}
    });
});
-->
</script>
</head>
<body class="gray-bg">

{if $goodsInfo[is_promote] <> 1}
    <style>.is_promote{ display:none;}</style>
{/if}

<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>商品内容</h5>
                </div>
                <div class="ibox-content">
                    <ul class="nav nav-tabs">
                        <li class="active"><a data-toggle="tab" href="#tab_tongyong"> 通用信息</a></li>
                        <li><a data-toggle="tab" href="#tab_xinxi"> 商品信息</a></li>
                        <li style="display: none;"><a href="#tab_goods_enginfo" data-toggle="tab">商品信息(英)</a></li>
                        <li><a data-toggle="tab" href="#tab_image" style=""> 商品相册</a></li>
                        <li><a data-toggle="tab" href="#tab_attr" style=""> 商品属性</a></li>
                        <li style="display: none;"><a data-toggle="tab" href="#tab_guige" style=""> 商品规格</a></li>
                        <li style="display: none;"><a data-toggle="tab" href="#tab-mobile"> 商品信息(手机)</a></li>
                    </ul>
                    <br/>
                    <div class="row">
                        <form method="post" id="addEditGoodsForm" class="form-horizontal">
                            <div class="tab-content">
                                <div id="tab_tongyong" class="tab-pane active">
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">商品分类：</label>
                                        <div class="col-sm-8">
                                            <select name="cat_id" id="cat_id"  class="form-control" onchange="ChangeCat()">
                                                <option value="0">请选择商品分类</option>
                                                {foreach name="cat_list" item="v" key="k" }
                                                    <option value="{$v['id']}" {if $v['id'] == $goodsInfo['cat_id']}selected="selected"{/if} >
                                                    {$v[space]}{$v['name']}
                                                    </option>
                                                {/foreach}
                                            </select>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">商品名称：</label>
                                        <div class="col-sm-8">
                                            <input type="text" value="{$goodsInfo.goods_name}" name="goods_name" class="configInput form-control"/>
                                            <span id="err_goods_name" style="color:#F00; display:none;"></span>
                                        </div>
                                    </div>
                                    
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">商品售价：</label>
                                        <div class="col-sm-8">
                                            <input type="text" value="{$goodsInfo.shop_price}" name="shop_price" class="configInput form-control" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')" onpaste="this.value=this.value.replace(/[^\d.]/g,'')" />
                                            <span id="err_shop_price" style="color:#F00; display:none;"></span>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">市场价：</label>
                                        <div class="col-sm-8">
                                            <input type="text" value="{$goodsInfo.market_price}" name="market_price" class="configInput form-control" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')" onpaste="this.value=this.value.replace(/[^\d.]/g,'')" />
                                            <span id="err_market_price" style="color:#F00; display:none;"></span>
                                        </div>
                                    </div>
                                    
                                    <div class="form-group" style="display: none;">
                                        <label class="col-sm-2 control-label">商品banner图片：</label>
                                        <div class="col-sm-8">
                                            <div class="input-group">
                                                <input type="text" class="form-control" name="banner_thumb" id="banner_thumb" value="{$goodsInfo.banner_thumb}" placeholder="请选择图片"> <span class="input-group-btn"> <button type="button" class="btn btn-primary" onclick="BrowseServer('banner_thumb');">选择图片</button> </span>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group" style="display: none;">
                                        <label class="col-sm-2 control-label">banner图片(手机)：</label>
                                        <div class="col-sm-8">
                                            <div class="input-group">
                                                <input type="text" class="form-control" name="p_banner_thumb" id="p_banner_thumb" value="{$goodsInfo.p_banner_thumb}" placeholder="请选择图片"> <span class="input-group-btn"> <button type="button" class="btn btn-primary" onclick="BrowseServer('p_banner_thumb');">选择图片</button> </span>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">商品图片：</label>
                                        <div class="col-sm-8">
                                            <div class="input-group uploder-container">
                                                <input type="text" class="form-control" name="thumb" id="thumb" value="{$goodsInfo.thumb}" placeholder="请选择商品图片"> 
                                                <span class="input-group-btn"> <button type="button" class="btn btn-primary filePicker">选择图片</button>
                                                </span>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group" style="display:none;">
                                        <label class="col-sm-2 control-label">商品重量：</label>
                                        <div class="col-sm-8">
                                            <input type="text" class="configInput form-control" value="{$goodsInfo.weight}" name="weight" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')" onpaste="this.value=this.value.replace(/[^\d.]/g,'')" />
                                        </div>
                                    </div>
                                    
                                    <div class="form-group" style="display:none;">
                                        <label class="col-sm-2 control-label">库存数量：</label>
                                        <div class="col-sm-8">
                                            <input class="configInput form-control" type="text" value="{$goodsInfo.store_count|default='99'}" name="store_count" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')" onpaste="this.value=this.value.replace(/[^\d.]/g,'')" />
                                            <span id="err_store_count" style="color:#F00; display:none;"></span>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">其他属性：</label>
                                        <div class="col-sm-8">
                                            <label class="checkbox-inline i-checks">
                                                <input type="checkbox" name="is_hide" value="1" {if $goodsInfo['is_hide'] == 1}checked="checked"{/if}>隐藏</label>
                                            <label class="checkbox-inline i-checks">
                                                <input type="checkbox" name="is_hot" value="1" {if $goodsInfo['is_hot'] == 1}checked="checked"{/if}>爆款</label>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">商品网页标题：</label>
                                        <div class="col-sm-8">
                                            <input type="text" value="{$goodsInfo.page_title}" name="page_title" class="configInput form-control"/>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">商品网页关键词：</label>
                                        <div class="col-sm-8">
                                            <input type="text" value="{$goodsInfo.keywords}" name="keywords" class="configInput form-control"/>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">商品网页描述：</label>
                                        <div class="col-sm-8">
                                            <input type="text" value="{$goodsInfo.description}" name="description" class="configInput form-control"/>
                                        </div>
                                    </div>
                                    <div class="form-group" style="display: none;">
                                        <label class="col-sm-2 control-label">商品购买链接：</label>
                                        <div class="col-sm-8">
                                            <input type="text" value="{$goodsInfo.shop_link}" name="shop_link" class="configInput form-control"/>
                                        </div>
                                    </div>
                                </div>
                                <div id="tab_image" class="tab-pane">
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">文章多图：</label>
                                        <div class="col-sm-8">
                                            <table class="table table-hover">
                                                <thead>
                                                    <tr>
                                                        <th style="width:30%">图片</th>
                                                        <!-- <th>链接地址（必填）</th> -->
                                                        <th style="width:30%">图片标题</th>
                                                        <th style="width:80px;">序号</th>
                                                        <th style="width:80px"><button type="button" id="btn" class="btn btn-sm btn-success"><i class="fa fa-plus-square"></i> 添加图片</button></th>
                                                    </tr>
                                                </thead>
                                                <tbody id="ul_pics">
                                                {foreach name="goodsInfo.pics_arr" item="v"}
                                                    <tr>
                                                        <td><input type="text" class="form-control upload-path" name="slide_img[]" value="{$v->image}"></td><td><input type="text" class="form-control" name="slide_alt[]" value="{$v->alt}" placeholder="请输入图片标题"></td><td><input type="number" class="form-control" name="slide_order[]" value="{$v->order}" placeholder="请输入图片序号"></td><td><button type="button" class="btn btn-sm btn-danger" onclick="$(this).parent().parent().remove()"><i class="fa fa-minus-square"></i> 删除</button></td>
                                                    </tr>
                                                {/foreach}
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>

                                </div>
                                <div id="tab_xinxi" class="tab-pane">
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">商品短介绍：</label>
                                        <div class="col-sm-8">
                                            <textarea class="form-control valid" name="short_content" rows="4">{$goodsInfo.short_content}</textarea>
                                        </div>
                                    </div>
                                    <div class="form-group" style="display:none">
                                        <label class="col-sm-2 control-label">商品规格：</label>
                                        <div class="col-sm-8">
                                            <textarea class="form-control valid" id="goods_norms" name="goods_norms">{$goodsInfo.goods_norms}</textarea>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">详情描述：</label>
                                        <div class="col-sm-8">
                                            <textarea id="goods_content" name="goods_content" rows="2" cols="20" style="height:300px">{$goodsInfo.goods_content|htmlspecialchars_decode}</textarea>
                                        </div>
                                    </div>
                                    <div class="form-group" style="display:none">
                                        <label class="col-sm-2 control-label">商品参数：</label>
                                        <div class="col-sm-8">
                                            <textarea class="form-control valid" id="goods_remark" name="goods_remark">{$goodsInfo.goods_remark}</textarea>
                                        </div>
                                    </div>
                                    <div class="form-group" style="display:none">
                                        <label class="col-sm-2 control-label">售后服务：</label>
                                        <div class="col-sm-8">
                                            <textarea class="form-control valid" id="goods_service" name="goods_service">{$goodsInfo.goods_service}</textarea>
                                        </div>
                                    </div>
                                </div>
                                <div id="tab-mobile" class="tab-pane">
                                    
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">详情描述：</label>
                                        <div class="col-sm-8">
                                            <textarea class="span12 ckeditor" id="p_goods_content" name="p_goods_content">{$goodsInfo.p_goods_content}</textarea>
                                        </div>
                                    </div>
                                </div>
                                <div id="tab_goods_enginfo" class="tab-pane">
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">商品名称(英)：</label>
                                        <div class="col-sm-8">
                                            <input type="text" value="{$goodsInfo.e_goods_name}" name="e_goods_name" class="configInput form-control"/>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">商品网页标题(英)：</label>
                                        <div class="col-sm-8">
                                            <input type="text" value="{$goodsInfo.e_page_title}" name="e_page_title" class="configInput form-control"/>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">商品网页关键词(英)：</label>
                                        <div class="col-sm-8">
                                            <input type="text" value="{$goodsInfo.e_keywords}" name="e_keywords" class="configInput form-control"/>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">商品描述词(英)：</label>
                                        <div class="col-sm-8">
                                            <input type="text" value="{$goodsInfo.e_description}" name="e_description" class="configInput form-control"/>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">商品规格(英)：</label>
                                        <div class="col-sm-8">
                                            <input type="text" value="{$goodsInfo.e_goods_norms}" name="e_goods_norms" class="configInput form-control"/>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">商品短介绍(英)：</label>
                                        <div class="col-sm-8">
                                            <textarea class="form-control valid" name="e_short_content" rows="4">{$goodsInfo.e_short_content}</textarea>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">商品参数(英)：</label>
                                        <div class="col-sm-8">
                                            <textarea class="form-control valid" id="e_goods_remark" name="e_goods_remark">{$goodsInfo.e_goods_remark}</textarea>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">商品详情描述(英)：</label>
                                        <div class="col-sm-8">
                                            <textarea class="span12 ckeditor" id="e_goods_content" name="e_goods_content" >{$goodsInfo.e_goods_content}</textarea>
                                        </div>
                                    </div> 
                                </div>

                                <div id="tab_attr" class="tab-pane">
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">属性值：</label>
                                        <div class="col-sm-8">
                                            <button type="button" class="btn btn-sm btn-success" onClick="AddAttrRow();"><i class="fa fa-plus-square"></i> 添加</button>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label"></label>
                                        <div class="col-sm-8">
                                            <table class="table table-hover">
                                                <thead>
                                                    <tr>
                                                        <th style="width:60%">名称</th>
                                                        <th style="width:80px">操作</th>
                                                    </tr>
                                                </thead>
                                                <?php $attr_row = 0; ?>
                                                <tbody id="AttrBoxs">
                                                    <volist name="goods_attributes" id="goods_attribute">
                                                        <tr id="attrTR_{$key}">
                                                            <td>
                                                                <select name="attribute[]" id="" class="form-control">
                                                                    <option value=""></option>
                                                                    <foreach name="attributes" item="attribute">
                                                                        <foreach name="attribute['sub_attrs']" item="sub_attr">
                                                                            <option value="{$sub_attr['id']}" <if condition="$goods_attribute['attr_id'] eq $sub_attr['id']">selected="selected"</if>>{$attribute['name']} / {$sub_attr['attr_name']}</option>
                                                                        </foreach>
                                                                    </foreach>
                                                                </select>
                                                            </td>
                                                            <td><button type="button" class="btn btn-sm btn-danger" onclick="delADDRow('attrTR_{$key}')"><i class="fa fa-minus-square"></i> 删除</button></td>
                                                        </tr>
                                                        <?php $attr_row++; ?>
                                                    </volist>
                                                    
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                                <div id="tab_guige" class="tab-pane">
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">规格：</label>
                                        <div class="col-sm-8">
                                            <button type="button" class="btn btn-sm btn-success" onClick="AddNormRow();"><i class="fa fa-plus-square"></i> 添加</button>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label"></label>
                                        <div class="col-sm-8">
                                            <table class="table table-hover">
                                                <thead>
                                                    <tr>
                                                        <th style="width:35%">名称</th>
                                                        <th style="width:35%">价格</th>
                                                        <th style="width:80px">操作</th>
                                                    </tr>
                                                </thead>
                                                <?php $norm_row = 0; ?>
                                                <tbody id="NormBoxs">
                                                    <volist name="norms" id="norm">
                                                        <tr id="normTR_{$key}">
                                                            <td>
                                                                <input type="hidden" class="form-control" name="guige[{$key}][id]" value="{$norm['id']}">
                                                                <input type="text" class="form-control" name="guige[{$key}][name]" value="{$norm['name']}">
                                                            </td>
                                                            <td>
                                                                <input type="text" class="form-control" name="guige[{$key}][price]" value="{$norm['price']}">
                                                            </td>
                                                            <td><button type="button" class="btn btn-sm btn-danger" onclick="delADDRow('normTR_{$key}')"><i class="fa fa-minus-square"></i> 删除</button></td>
                                                        </tr>
                                                        <?php $norm_row++; ?>
                                                    </volist>
                                                    
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-2">
                                    <input type="hidden" name="goods_id" value="{$goodsInfo.goods_id}">
                                    <input type="hidden" name="act" value="{$act}">
                                    <input type="hidden" name="sel_id" value="{$sel_id}">
                                    <button class="btn btn-primary" onclick="ratuo_submit_form('addEditGoodsForm','{$goodsInfo.handle_url}');" type="button">保存</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

</div>
<script type="text/javascript" src="/public/static/admin/js/webupload.js"></script>
<script type="text/javascript" src="/public/static/admin/js/plupload.js"></script>
<!-- 规格 -->
<script>
    // var normItem = <?php echo $norm_row; ?>;
    // var normHtml = '';
    // normHtml += '<tr id="normTR_{0}">';
    // normHtml += '    <td>';
    // normHtml += '        <input type="hidden" class="form-control" name="guige[{0}][id]">';
    // normHtml += '        <input type="text" class="form-control" name="guige[{0}][name]">';
    // normHtml += '    </td>';
    // normHtml += '    <td>';
    // normHtml += '        <input type="text" class="form-control" name="guige[{0}][price]">';
    // normHtml += '    </td>';
    // normHtml += '    <td><button type="button" class="btn btn-sm btn-danger" onclick="delADDRow(\'normTR_{0}\')"><i class="fa fa-minus-square"></i> 删除</button></td>';
    // normHtml += '</tr>';
    // function AddNormRow(){
    //     var normHtmlTr = normHtml.replace(/\{0\}/g, normItem);
    //     $('#NormBoxs').append(normHtmlTr);
    //     normItem += 1;
    // }
</script>
<!-- 属性js -->
<script>
    //栏目改变，属性组改变
    var attr = [];
    function ChangeCat(){
        var catId = $('#cat_id').val();
        $.ajax({
            url:'/index.php/Admin/Goods/ajaxGoodsCatAttr',
            type:'post',
            dataType:'json',
            data:{catId:catId},
            success:function(data){
                if(data.status==1){
                    attr = data.data;
                    console.log(attr);
                }
            },
        })
    }

    var attrItem = <?php echo $attr_row; ?>;
    function AddAttrRow(){
        var attrHtml = '<tr id="attrTR_{0}">';
        attrHtml += '<td>';
        attrHtml += '<select name="attribute[]" id="" class="form-control">';
        attrHtml += '<option value=""></option>';
        for (var i=0;i<attr.length;i++){
            attrHtml += '<option value="'+attr[i].id+'">'+attr[i].name+'</option>';
        }
        
        attrHtml += '</select>';

        attrHtml += '</td>';
        attrHtml += '<td><button type="button" class="btn btn-sm btn-danger" onclick="delADDRow(\'attrTR_{0}\')"><i class="fa fa-minus-square"></i> 删除</button></td>';
        attrHtml += '</tr>';

        var attrHtmlTr = attrHtml.replace(/\{0\}/g, attrItem);
        $('#AttrBoxs').append(attrHtmlTr);
        attrItem += 1;
    }
    function delADDRow(id){
        $("#"+id).remove();
    }
</script>


<script type="text/javascript">
    $(function(){
        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_square-green',
            radioClass: 'iradio_square-green',
        });
        ChangeCat();
    })

    var htmlText = '<tr id="slideTR_{0}">';
    htmlText += '<td><div class="input-group"><input type="text" class="form-control" name="thumb_list[]" id="thumb_list{0}" value=""> <span class="input-group-btn"> <button type="button" class="btn btn-primary" onclick="BrowseServer(\'thumb_list{0}\');">选择图片</button> </span></div></td>';
    htmlText += '<td><button type="button" class="btn btn-sm btn-danger" onclick="delmySlideRow({0})"><i class="fa fa-minus-square"></i> 删除</button></td></tr>';
    var items = 1;

    function addSlideRow() {
        var lastitem = items - 1;
        var newHtmlTr = htmlText.replace(/\{0\}/g, items);
        $('#SildeImgs').append(newHtmlTr);
        items += 1;
    }
    function delmySlideRow(id) {
        $("#slideTR_" + id).remove();
    } 

</script>


<script>


</script>


<script>



// 属性输入框的加减事件
function addAttr(a)
{
    var attr = $(a).parent().parent().prop("outerHTML");    
    attr = attr.replace('addAttr','delAttr').replace('+','-');  
    $(a).parent().parent().after(attr);
}
// 属性输入框的加减事件
function delAttr(a)
{
   $(a).parent().parent().remove();
}
 



</script>
</body>
</html>